
package com.jf.cloud.order.config;

import com.jf.cloud.common.rocketmq.config.RocketMqAdapter;
import com.jf.cloud.common.rocketmq.config.RocketMqConstant;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

/**
 * @author zz
 * @date 2021/3/30
 */
@RefreshScope
@Configuration
public class RocketMqConfig {

    @Autowired
    private RocketMqAdapter rocketMqAdapter;

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate stockMqTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.STOCK_UNLOCK_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate couponMqTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.COUPON_UNLOCK_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate orderCancelTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.ORDER_CANCEL_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate orderPurchaseNotifyShopTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.ORDER_PURCHASE_NOTIFY_SHOP_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate orderNotifyServiceTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.ORDER_NOTIFY_SERVICE_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate orderReceiptTemplate() {
        return rocketMqAdapter.getTransactionTemplateByTopicName(RocketMqConstant.ORDER_RECEIPT_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate orderSettledShopTemplate() {
        return rocketMqAdapter.getTransactionTemplateByTopicName(RocketMqConstant.ORDER_SETTLED_SHOP_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate orderRefundTemplate() {
        return rocketMqAdapter.getTransactionTemplateByTopicName(RocketMqConstant.ORDER_REFUND_TOPIC);
    }


    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate orderRefundPaymentTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.ORDER_REFUND_PAYMENT_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate orderRefundShopTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.ORDER_REFUND_SHOP_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate orderRefundSuccessSettlementTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.ORDER_REFUND_SUCCESS_SETTLEMENT_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate refundSuccessNotifySupplierTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.ORDER_REFUND_SUCCESS_SETTLEMENT_SUPPLIER_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate orderRefundSuccessServiceTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.ORDER_REFUND_SUCCESS_SERVICE_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate orderRefundSuccessStockTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.ORDER_REFUND_SUCCESS_STOCK_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate groupOrderCancelMqTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.GROUP_ORDER_CANCEL_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate seckillOrderCancelMqTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.SECKILL_ORDER_CANCEL_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate seckillOrderRefundMqTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.SECKILL_ORDER_REFUND_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate sendNotifyToShopTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.SEND_NOTIFY_TO_SHOP_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate sendNotifyToUserTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.SEND_NOTIFY_TO_USER_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate userScoreTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.SCORE_UNLOCK_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate sendNotifyToUserExtensionTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.SEND_NOTIFY_TO_USER_EXTENSION_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate stockBillLogTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.STOCK_BILL_LOG_TOPIC);
    }
//
//    @Lazy
//    @Bean(destroyMethod = "destroy")
//    public RocketMQTemplate lockShopWalletAmountTemplate() {
//        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.LOCK_SHOP_WALLET_AMOUNT_TOPIC);
//    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate orderSettledSupplierTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.ORDER_SETTLED_SUPPLIER_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate outStockLogTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.OUT_STOCK_LOG_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate orderNotifyTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.ORDER_NOTIFY_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate orderPreSaleFailSettlementTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.ORDER_PRE_SALE_FAIL_SETTLEMENT_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate presaleOrderCanalMqTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.PRESALE_ORDER_CANAL_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate orderRefundCancelMqTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.ORDER_REFUND_CANAL_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate comboOrderMqTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.COMBO_ORDER_TOPIC);
    }


    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate sendOrderToPurchaseNotifyToShopTemplate() {
        return rocketMqAdapter.getTransactionTemplateByTopicName(RocketMqConstant.SEND_ORDER_TO_PURCHASE_NOTIFY_TO_SHOP_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate deleteShopCartItemTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.DELETE_SHOP_CART_ITEM_TOPIC);
    }
}
